--- for debug
local custom = require "map/levels".custom_levels

RG_LEVELS = {}

RG_LEVELS_INDEX = {}

GLOBAL.RG_LEVELS = RG_LEVELS

function RG_AddLevel(data)
	-- Generic overrides
	if data.overrides == nil then
		data.overrides = {}
	end

	for k,v in pairs{
		boons = "never",
		traps = "never",
		poi   = "never",
		protected = "never",
		world_size = "tiny",

	}do
		local temp = {k, v}
		for _, override in pairs(data.overrides)do
			if override[1] == k then
				temp = nil 
				break
			end
		end
		if temp ~= nil then
			table.insert(data.overrides, temp)
		end
	end

	if data.nomaxwell == nil then
		data.nomaxwell = true
	end

	-- API
	env.AddLevel(LEVELTYPE.CUSTOM, data)

	local index = #custom
	local level = custom[index]
	RG_LEVELS[level.id] = level
	RG_LEVELS_INDEX[level.id:upper()] = index
	RG_LEVELS_INDEX[level.id:lower()] = index
	return level
end

PROPERTIES = {
	barren = function(t) return {data = {pickable = {picked = true, time = t or 99999}}} end,
	-- sleeping = function() return {data = }
}

function randgen(a, b)
	return function() return math.random(a, b) end
end

for _,v in ipairs{
	"start",
	"foresttrail",
	-- "fingertop",
	"paraworld",
}do
	modimport ("modworldgenmain/levels/level_"..v..".lua")
end
